<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <script>
        //属性简写
        let name = "张三";
        let age = 15;
        let obj = {
            //name:name   age:age
            name,
            age
        }
        console.log(obj.name);
        console.log(obj.age);
        //方法简写
        let obj1 = {
            //fun:function(){console.log(133)}
            fun() { console.log(133) }
        }
        obj1.fun();



        //assign方法   和$.extend一样
        let a = { name: "德萨" }
        let b = { age: 19 }
        let c = {}
        let e = Object.assign(a, b, c);




        let obj4 = {
            name: "张三",
            age: 18,
            gender: "男",
            hobbies: ["吃", "喝", "玩"]
        }
        function fun(arr) {
            let obj5 = Object.assign({}, arr);
            console.log(obj5);
        }
        fun(obj4);





        console.log(e);
        b.age = 20;
        console.log(e);
        console.log(a);
        //key方法  
        let f = Object.keys(e);
        //属性名
        console.log(f);
        let g = Object.values(e);
        //属性值
        console.log(g);

        //json字符串 压缩为 json字符串
        let i = JSON.stringify(e);
        console.log(i);
        //json字符串 解压为 js数据
        let h = JSON.parse(i);
        console.log(h);




        let obj8 = {
            name: "李四",
            age: "18",
            skill: ["吃", "喝", "玩", "乐"]
        };
         function clone(arr){
            let pro=JSON.stringify(arr);
            let sol=JSON.parse(pro);
            console.log(sol);
         }
        //  obj8.name="文物";
        clone(obj8);
        obj8.name="文物";
        console.log(obj8);






        //symbol方法
        let nam=Symbol("name");
        let ag=Symbol("age");
        let obj2={
            [nam]:"111",
            [ag]:"19"
        }
        console.log(obj2);
    </script>
</body>

</html>